#ifndef SYSROOT_CTYPE_H_
#define SYSROOT_CTYPE_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <features.h>

int isalnum(int);
int isalpha(int);
int isblank(int);
int iscntrl(int);
int isdigit(int);
int isgraph(int);
int islower(int);
int isprint(int);
int ispunct(int);
int isspace(int);
int isupper(int);
int isxdigit(int);
int tolower(int);
int toupper(int);

#ifndef __cplusplus
static __inline int __isspace(int _c) { return _c == ' ' || (unsigned)_c - '\t' < 5; }

#define isalpha(a) (0 ? isalpha(a) : (((unsigned)(a) | 32) - 'a') < 26)
#define isdigit(a) (0 ? isdigit(a) : ((unsigned)(a) - '0') < 10)
#define islower(a) (0 ? islower(a) : ((unsigned)(a) - 'a') < 26)
#define isupper(a) (0 ? isupper(a) : ((unsigned)(a) - 'A') < 26)
#define isprint(a) (0 ? isprint(a) : ((unsigned)(a)-0x20) < 0x5f)
#define isgraph(a) (0 ? isgraph(a) : ((unsigned)(a)-0x21) < 0x5e)
#define isspace(a) __isspace(a)
#endif

#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
    defined(_GNU_SOURCE) || defined(_BSD_SOURCE)

int isascii(int);
int toascii(int);
#define _tolower(a) ((a) | 0x20)
#define _toupper(a) ((a)&0x5f)
#define isascii(a) (0 ? isascii(a) : (unsigned)(a) < 128)

#endif

#ifdef __cplusplus
}
#endif

#endif  // SYSROOT_CTYPE_H_
